<template>
	<view :class="[BackGround]" :style="[{'font-weight':Style,'font-family':Font,height:height + 'px'}]">
		<cu-custom bgColor="bg-gradual-blue" isBack="true" @openMenu="openMenu">
			<view slot="backText">返回</view>
			<view slot="content">档案录入</view>
		</cu-custom>
		<view :class="['margin-xs radius shadow shadow-lg bg-white',BackGroundBox]" v-if="isShow">
			<form @submit="formSubmit" @reset="formReset">
				<view :style="{marginBottom:bottom + 'rpx'}">
					<view class="cu-form-group">
						<view class="title">机器编号</view>
						<input type="text" disabled placeholder="系统自动生成" />
					</view>
					<view class="cu-form-group">
						<view class="title">IP地址</view>
						<input type="text" placeholder-class="" name="LIP" placeholder="可选值" />
					</view>
					<view class="cu-form-group">
						<view class="title">机器地址</view>
						<input type="text" name="LMAC" placeholder="可选值" />
					</view>
					<view class="cu-form-group">
						<view class="title">生产车间</view>
						<picker @change="PickerChange1" name="LCLASSINDEX" :value="index1" :range="picker1" range-key="LNAME">
							<view class="picker">
								{{picker1[index1].LNAME}}
							</view>
						</picker>
					</view>
					<view class="cu-form-group">
						<view class="title">工序类别</view>
						<picker @change="PickerChange2" name="LTYPE" :value="index2" :range="picker2" range-key="LNAME">
							<view class="picker">
								{{picker2[index2].LNAME}}
							</view>
						</picker>
					</view>
					<view class="cu-form-group">
						<view class="title">机器类别</view>
						<picker @change="PickerChange4" name="LPRCTYPE" :value="index4" :range="picker4" range-key="LNAME">
							<view :class="['picker',index4 === -1 ? 'text-grey5' : 'text-black']">
								{{index4>-1?picker4[index4].LNAME:'请选择'}}
							</view>
						</picker>
					</view>
					<view class="cu-form-group">
						<view class="title">机器型号</view>
						<input type="text" disabled :value="picker4[index4].LCODE" name="LMACHINETYPE" />
					</view>
					<view class="cu-form-group">
						<view class="title">是否有效</view>
						<switch name="LISUSED" @change="SwitchA" :class="switchA?'checked':''" :checked="switchA?true:false"></switch>
					</view>
					<view class="cu-form-group">
						<view class="title">备注</view>
						<!-- <textarea placeholder="请输入备注" :fixed="true" type="text" name="LREMARK" ></textarea> -->
						<input :adjust-position="false" v-model="LREMARK" @focus="focus" @blur="blur" placeholder="请输入备注" type="text" name="LREMARK" />
					</view>
				</view>
				<button-father :Position="'tb-fa-fixed'">
					<button class="cu-btn bg-blue-gradual  lg shadow tb-flex cu-btn-new" form-type="reset">重置</button>
					<button class="cu-btn bg-gradual-blue  lg shadow tb-flex cu-btn-new" form-type="submit">确认</button>
				</button-father>
			</form>
		</view>
		<!--顶部下拉菜单-->
		<zyt-input tui-top-dropdown="tui-top-dropdown" bgcolor="rgba(76, 76, 76, 0.95)" :show="menuShow" :height="0"
		 @close="closeMenu" :zvalue="LREMARK" @zblur="zblur">
		</zyt-input>
		<!---顶部下拉菜单-->
	</view>
</template>

<script>
	import ButtonFather from "@/colorui/components/ButtonFather.vue";
	import zytInput from '@/colorui/components/input.vue'
	import {
		mapGetters
	} from 'vuex'
	import {
		getselectReferList
	} from "@/service/selectList.js"
	import {
		postinsert
	} from "@/service/insert.js"
	export default {
		data() {
			return {
				height:this.screenHeight,
				LREMARK:"",
				menuShow:false,
				zvalue:"",
				bottom:100,
				switchA: true,
				isShow: false,
				picker1: [],
				index1: 0,
				picker2: [],
				index2: 0,
				picker4:[],
				index4:0
			}
		},
		components: {
			ButtonFather,
			zytInput
		},
		computed: {
			...mapGetters(['Style','Font','BackGround','BackGroundBox'])
		},
		onLoad() {
			// console.log(this.$style.uni_bg_color_night);
			// setInterval(res => {
			// 	this.$style.uni_bg_color_night = '#ffffff';
			// 	console.log('完成了');
			// },5000)
			getselectReferList(9538, '表头', 'LCLASSINDEX', {}).then(res => {
				if (res.code != 0) {
					this.picker1 = res.data
				} else {
					this.isShow = true
				}
			})
			getselectReferList(9538, '表头', 'LTYPE', {}).then(res => {
				if (res.code != 0) {
					this.picker2 = res.data
					this.isShow = true
				} else {
					this.isShow = true
				}
			})
			getselectReferList(9538, '表头', 'LPRCTYPE', {}).then(res => {
				if (res.code != 0) {
					this.picker4 = res.data
					this.isShow = true
				} else {
					this.isShow = true
				}
			})
		},
		methods: {
			PickerChange1(e) {
				this.index1 = e.detail.value
			},
			PickerChange2(e) {
				this.index2 = e.detail.value
			},
			PickerChange4(e) {
				this.index4 = e.detail.value
			},
			SwitchA(e) {
				this.switchA = e.detail.value
			},
			focus(e) {
				this.menuShow = true
				this.LREMARK = e.detail.value
			},
			openMenu() {
				this.menuShow = false
			},
			zblur(value) {
				console.log(value);
				this.LREMARK = value
			},
			blur() {
				
			},
			closeMenu() {
				this.menuShow = false
			},
			formSubmit(e) {
				e.detail.value['LCLASSINDEX'] = this.picker1[this.index1].LNAME
				e.detail.value['LTYPE'] = this.picker2[this.index2].LNAME
				e.detail.value['LPRCTYPE'] = this.picker4[this.index4].LNAME
				e.detail.value['LUID'] = 0
				e.detail.value['LMACHINENO'] = 'auto'
				e.detail.value['LSTATERUN'] = 0
				e.detail.value['LSTATUS'] = 1
				let data = e.detail.value
				postinsert(953801,global.userinfo.lusercode,{'table':data}).then(res => {
					if (res.code == 1) {
						global.Return = true
						uni.navigateBack({
							delta: 1
						});
						uni.showToast({
							title: '录入成功',
							icon: 'success',
							duration: 3000
						});
					}
				})
			},
			formReset() {

			}
		}
	}
</script>

<style lang="scss">
</style>
